<?php

/**
 * 链接页面配置logic
 */

namespace Member\Logic;

class LinkurlLogic extends CommonLogic {
	
    
	//获取全部的链接url信息
	public function allLists(){
		
		$linkurl = array();
		
		//获取系统的url
		$moudleurlLogic = D('Module','Logic');
		$modules = $moudleurlLogic->allLists();
		foreach ($modules as $k => $v){
		    $modules[$k]['url'] = $v['name'];
			if($v['name']=='coupon'){
				unset($modules[$k]);
			}	
		}
		$linkurl['modules'] = &$modules;

		//本地优惠一级类别
		$couponClassifyLogic = D('CouponClassify','Logic');
		$coupon = $couponClassifyLogic->where(array('pid'=>0))->field('id,classify')->select();
		foreach($coupon as &$v){
			$v['title'] = $v['classify'];
			$v['url'] = apiurl('coupon').'/pid/'.$v['id'];
		}
		$linkurl['coupon'] = &$coupon; 
		
		//获取自定义url
		$UrlsLogic = D('Urls','Logic');
		$urls = $UrlsLogic->allLists();
		foreach ($urls as &$v){
			$v['title'] = $v['name'];
		}
		$linkurl['urls'] = &$urls;
		
	    //历史轮播
		$historyLogic = D('HistoryArticles','Logic');
		$history = $historyLogic->where(array('uid'=>UID,'carousel'=>1))->field('id,title')->select();
		foreach($history as &$v){
			$v['url'] = apiurl('history').'/id/'.$v['id'];
		}
		$linkurl['history'] = &$history;
		
		//萌宝大赛
		$baby['index'] = 'baby/index/u/'.UID;
		$baby['rule'] = 'baby/rule/u/'.UID;	
		$baby['join'] = 'baby/join/u/'.UID;
		$baby['prize'] = 'baby/prize/u/'.UID;
		$baby['cheat'] = 'baby/cheat/u/'.UID;
		
		$linkurl['baby'] = &$baby;
		
		return $linkurl;
	}

	

	
	
	
}